/*
 * Application Name: 工作票信息管理系统
 * Desc: 热力机械工作票
 * Author: Albert 
 * Date: 2009-07-30
 */
Ext.extend(workpaper.baseModule,{	
    init: function(){    	
		this.childTabPanel =  new Ext.TabPanel({            	
	        id:'child_tabPanel_m104',				        
	        activeTab:0,				        
	        margins:'0 0 0 0',
	        split:true,
	        resizeTabs:true,
	        tabWidth:150,
	        minTabWidth: 65,
	        enableTabScroll:true,	        
	        plugins: new Ext.ux.TabCloseMenu(),
	        viewConfig: {
	            forceFit:true
	        }	        				        
	    });
	    
		this.mainFormMenu1 = new Ext.menu.Menu({
			id: 'mainFormMenu1_m104',
			items: [
			 {
			 	id:'mainFormMenu1_save_m104',
			 	//handler: onMainFormMenu1_saveClick,
				text: '保 存'			
			 },	{
			 	id:'mainFormMenu1_del_m104',
			 	//handler: onMainFormMenu1_delClick,
				text: '删 除'			
			 },	{
			 	id:'mainFormMenu1_attach_m104',
			 	handler: this.onMainFormMenu1_attachClick,
				text: '添加附页'			
			 },	{
			 	id:'mainFormMenu1_card_m104',
			 	handler: this.onMainFormMenu1_cardClick,
				text: '添加危险点与控制措施卡'			
			 },	{
			 	id:'mainFormMenu1_print_m104',
			 	handler:  function(menuItem){
    						workpaper.ux.tools.openPrinterWindow("print_Content_m104","热力机械工作票");    		
						},
				text: '打印'			
			 }
			]
		});
		
		this.mainFormMenu2 = new Ext.menu.Menu({
			id: 'mainFormMenu2_m104',
			items: [
			{
			 	id: this.cardId + '_model',
			 	//handler: onCardFormMenu_modelClick,
				text: '保存为模板'			
			 },{
			 	id: this.cardId + '_modelFill',
			 	handler: this.onMainFormMenu2_modelFillClick,
				text: '用模板填充'			
			 },
			 {
			 	id:'mainFormMenu2_save_m104',
			 	//handler: onMainFormMenu2_saveClick,
				text: '送签发'			
			 },	{
			 	id:'mainFormMenu2_del_m104',
			 	//handler: onMainFormMenu2_delClick,
				text: '签 发'			
			 },	{
			 	id:'mainFormMenu2_attach_m104',
			 	//handler: onMainFormMenu2_attachClick,
				text: '签 收'			
			 },	{
			 	id:'mainFormMenu2_card_m104',
			 	//handler: onMainFormMenu2_cardClick,
				text: '工作许可'			
			 },	{
			 	id:'mainFormMenu2_print_m104',
			 	//handler: onMainFormMenu2_printClick,
				text: '终 结'			
			 }
			]
		});
		
			      
		this.mainForm = new Ext.FormPanel({
			id: 'mainFormPanel_m104',			
			layout:'fit',
			margins:'0 0 0 0',
			frame: true,
			autoScroll: true,
			//defaults:{bodyStyle:'padding:10px'},
			title: '工作票主页',
			tbar: [
	           {	                        
                id: 'mainMenuBtn1_m104',	                        
                text:'主页操作',
                tooltip: {title:'',text:'针对当前工作票主页的操作菜单'},
                iconCls: 'preview-hide',
                menu: this.mainFormMenu1
	           },
	           {	                        
                id: 'mainMenuBtn2_m104',	                        
                text:'工作票处理',
                tooltip: {title:'',text:'针对当前工作票处理的操作菜单'},
                iconCls: 'preview-bottom',
                menu: this.mainFormMenu2
	           }
	        ],	        
	        html: "<div id='print_Content_m104' width='680'><table style='background-color:white;padding:4px;white-space:nowrap;color:black;font-size:12px;' width='680' align='center' border='0'><tr><td align='center'><span style='font-size:22' align='center'><b>舟山朗熹发电有限责任公司<br>热&nbsp;&nbsp;力&nbsp;&nbsp;机&nbsp;&nbsp;械&nbsp;&nbsp;工&nbsp;&nbsp;作&nbsp;&nbsp;票</b></span></td></tr><tr height='25'><td><tr height='25'><td>部门（单位）：<input type='text' class='input' name='dept' id='dept_m104' style='width:160' />班组：<input type='text' class='input' name='workUnit' id='workUnit_m104' style='width:140' />编号：<input type='text' class='input' name='paperId' id='paperId_m104' style='width:125' readonly='true'/>附页：<input type='text' class='input' name='attachPages' id='attachPages_m104' style='width:30' />张</td></tr><tr height='25'><td>1、工作负责人：<input type='text' class='input' name='principal' id='principal_m104' style='width:170' /></td></tr><tr height='25'><td>2、工作班人员（不包括工作负责人）：<input type='text' class='input' name='workers' id='workers_m104' style='width:400' />共<input type='text' class='input' name='workerNum' id='workerNum_m104' style='width:25' />人</td></tr><tr height='75'><td>3、工作内容（包括工作地点和设备名称）：<textarea class='input' rows=3 name='task' id='task_m104' style='overflow:hidden;width:430'></textarea></td></tr><tr height='25'><td>4、计划工作时间： 自&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' class='input' name='planTimeStart' id='planTimeStart_m104' style='width:160' /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;开始至&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' class='input' name='planTimeEnd' id='planTimeEnd_m104' style='width:160' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;结束</td></tr><tr height='25'><td>5、安全措施：（必要时可附页绘图说明）</td></tr><tr><td><div id='grid01_m104'></div></td></tr><tr><td><div id='grid02_m104' width='675'></div></td></tr><tr height='25'><td>&nbsp;&nbsp;工作票填写人：<input type='text' class='input' name='fillMan' id='fillMan_m104' style='width:120' /> 工作票签发人：<input type='text' class='input' name='sendOutMan' id='sendOutMan_m104' style='width:120' /> 签发时间：<input type='text' class='input' name='sendOutTime' id='sendOutTime_m104' style='width:160' /></td></tr><tr height='25'><td>6、收到工作票时间：&nbsp;&nbsp;<input type='text' class='input' name='signInTime' id='signInTime_m104' style='width:160' />&nbsp;&nbsp;&nbsp; 接票人签名：<input type='text' class='input' name='signInMan' id='signInMan_m104' style='width:120' /></td></tr><tr height='90'><td>&nbsp;</td></tr><tr><td><div id='grid03_m104' width='675'></div></td></tr><tr height='25'><td>8、批准工作结束时间：&nbsp;&nbsp;<input type='text' class='input' name='approveEndTime' id='approveEndTime_m104' style='width:160' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;值长：<input type='text' class='input' name='curRunLeader' id='curRunLeader_m104' style='width:110' />， (日期)<input type='text' class='input' name='curRunLeaderTime' id='curRunLeaderTime_m104' style='width:110' /></td></tr><tr height='25'><td>单元长：<input type='text' class='input' name='unitLeader' id='unitLeader_m104' style='width:85' />， (日期)<input type='text' class='input' name='unitLeaderTime' id='unitLeaderTime_m104' style='width:110' /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;工作许可人：<input type='text' class='input' name='permissiveMan' id='permissiveMan_m104' style='width:85' />， (日期)<input type='text' class='input' name='permissiveManTime' id='permissiveManTime_m104' style='width:110' /></td></tr><tr height='25'><td>9、确认本工作票1～8项，许可工作时间：自&nbsp;&nbsp;&nbsp;<input type='text' class='input' name='permissiveTime' id='permissiveTime_m104' style='width:160' />&nbsp;&nbsp;&nbsp;许可工作开始，</td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;工作许可人：<input type='text' class='input' name='permissiveMan' id='permissiveMan_m104' style='width:100' />  &nbsp;&nbsp;&nbsp;工作负责人：<input type='text' class='input' name='principalPermission' id='principalPermission_m104' style='width:100' /></td></tr><tr height='25'><td>10.确认工作负责人布置的工作任务和安全措施，工作班成员签名：</td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;<input type='text' class='input' name='workersSign' id='workersSign_m104' style='width:640' readonly='true'/></td></tr><tr height='25'><td>11、工作人员变动情况：</td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;(1)工作负责人变更：自&nbsp;&nbsp;<input type='text' class='input' name='principalChgTime' id='principalChgTime_m104' style='width:160' />&nbsp;&nbsp;，原工作负责人<input type='text' class='input' name='oldPrincipal' id='oldPrincipal_m104' style='width:85' />离去，变更为 <input type='text' class='input' name='newPrincipal' id='newPrincipal_m104' style='width:85' /></td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;担任工作负责人。&nbsp;&nbsp;工作票签发人：<input type='text' class='input' name='chgSendOutMan' id='chgSendOutMan_m104' style='width:110' />&nbsp;&nbsp;&nbsp;&nbsp; 工作许可人：<input type='text' class='input' name='chgPermissiveMan' id='chgPermissiveMan_m104' style='width:110' /></td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;(2)工作班人员变动：原工作班人员 <input type='text' class='input' name='chgOldWorker' id='chgOldWorker_m104' style='width:155' />离去，增加<input type='text' class='input' name='chgNewWorker' id='chgNewWorker_m104' style='width:140' />为工作班成员。</td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;工作负责人：<input type='text' class='input' name='chgWorkerPrincipal' id='chgWorkerPrincipal_m104' style='width:120' />，&nbsp;&nbsp;(时间)<input type='text' class='input' name='chgWorkerPrincipalTime' id='chgWorkerPrincipalTime_m104' style='width:160' /></td></tr><tr height='25'><td>12、工作票延期：有效期延长到&nbsp;&nbsp;&nbsp;<input type='text' class='input' name='permissiveTime' id='permissiveTime_m104' style='width:160' />&nbsp;&nbsp;。</td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;值长：<input type='text' class='input' name='curRunLeaderDelay' id='curRunLeaderDelay_m104' style='width:90' />&nbsp;&nbsp;单元长：<input type='text' class='input' name='unitLeaderDelay' id='unitLeaderDelay_m104' style='width:90' />&nbsp;&nbsp;工作许可人：<input type='text' class='input' name='permissiveManDelay' id='permissiveManDelay_m104' style='width:90' />&nbsp;&nbsp;工作负责人：<input type='text' class='input' name='principalDelay' id='principalDelay_m104' style='width:90' /></td></tr><tr height='25'><td>13、工作票终结：工作人员已全部撤离，现场已清理完毕。全部工作于&nbsp;&nbsp;&nbsp;<input type='text' class='input' name='endTime' id='endTime_m104' style='width:160' />&nbsp;&nbsp;&nbsp;&nbsp;结束。</td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;工作负责人：<input type='text' class='input' name='endPrincipal' id='endPrincipal_m104' style='width:120' />&nbsp;&nbsp;&nbsp;&nbsp; 工作许可人：<input type='text' class='input' name='endPermissiveMan' id='endPermissiveMan_m104' style='width:120' /></td></tr><tr height='25'><td>14、检修设备试运后，工作票所列安全措施已全部执行，可以工作：</td></tr><tr><td><div id='grid04_m104' width='675'></div></td></tr><tr height='25'><td>15、备注：</td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;(1)指定专职监护人：<input type='text' class='input' name='wardMan' id='wardMan_m104' style='width:120' />负责监护：(在下行填写监护地点及具体工作)</td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;<input type='text' class='input' name='wardContent' id='wardContent_m104' style='width:640' readonly='true'/></td></tr><tr height='25'><td>&nbsp;&nbsp;&nbsp;(2)其他事项：<input type='text' class='input' name='paperRemark' id='paperRemark_m104' style='width:560' />。</td></tr><tr height='50'><td>&nbsp;</td></tr><tr height='25'><td align='right'><i>热力机械工作票第二页，编号：<input type='text' class='input' name='paperId' id='paperId_m104' style='width:125' readonly='true'/><i></td></tr></table></div>"		
		});		
		this.mainForm.on("afterrender",this.showEditGrid,this);
				       	
    	this.childTabPanel.add(this.mainForm);    		
        this.tab.add(this.childTabPanel);
        this.tab.doLayout();
    },
    
    destroy: function(){    	 	
		Ext.destroy(Ext.getCmp("mainFormMenu1_m104"),
					Ext.getCmp("mainFormMenu2_m104"),
					Ext.getCmp("mainFormPanel_m104"),
					Ext.getCmp("child_tabPanel_m104")					
		); 
		this.init = null; 
		//待完善。  	
    },
    
    
    showEditGrid : function(){    	    	
    	//document.getElementById("grid01_m104").innerHTML = "";    	
    	var ds01 = new workpaper.store.dealPaper.rljxGridFirstStore();    	 
	    var cm01 = new Ext.grid.ColumnModel([{
	           id: 'col1',
	           header: "5.1：检修工作要求工作许可人员执行的安全措施",
	           dataIndex: 'col1',
	           width: 560,	           
	           editable: true,
	           align: 'left',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfContent()     
	        },{
	           id: 'col2',
	           header: "已执行",
	           dataIndex: 'col2',
	           width: 115,	           	           
	           align: 'center',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfExecution()      	            
	    }]);
	    cm01.defaultSortable = false;
	   
	    var grid01 = new Ext.grid.EditorGridPanel({
	    	id: 'editgrid01_m104',
	    	renderTo: 'grid01_m104',	    	
	    	layout: 'fit',
	        store: ds01,
	        cm: cm01,	        
	        width: 675,
	        height: 435,
	        autoExpandColumn: 'col1',
	        stripeRows:true,
	        columnLines : true,
	        //plugins: checkColumn,
	        viewConfig : {
	            forceFit: true,	            
	            scrollOffset: 0 // the grid will never have scrollbars
	        },
	        clicksToEdit: 2
	    });		    
	    
    	//document.getElementById("grid02_m104").innerHTML = "";    	
    	var ds02 = new workpaper.store.dealPaper.rljxGridSecondStore();    	 
	    var cm02 = new Ext.grid.ColumnModel([{
	           id: 'col1',
	           header: "5.2：检修工作要求检修人员自行执行的安全措施",
	           dataIndex: 'col1',
	           width: 560,	           
	           editable: true,
	           align: 'left',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfContent() 
	        },{
	           id: 'col2',
	           header: "已执行",
	           dataIndex: 'col2',
	           width: 57,	           	           
	           align: 'center',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfExecution()
	        },{
	           id: 'col3',
	           header: "已恢复",
	           dataIndex: 'col3',
	           width: 58,	           	           
	           align: 'center',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfExecution()
	    }]);
	    cm02.defaultSortable = false;
	    
	    var grid02 = new Ext.grid.EditorGridPanel({
	    	id: 'editgrid02_m104',
	    	renderTo: 'grid02_m104',	    	
	    	layout: 'fit',
	        store: ds02,
	        cm: cm02,	        
	        width: 675,
	        height: 125,
	        autoExpandColumn: 'col1',
	        stripeRows:true,
	        columnLines : true,
	        //plugins: checkColumn,
	        viewConfig : {
	            forceFit: true,	            
	            scrollOffset: 0 // the grid will never have scrollbars
	        },
	        clicksToEdit: 2
	    });	
	    
	    
    	//document.getElementById("grid03_m104").innerHTML = "";    	
    	var ds03 = new workpaper.store.dealPaper.rljxGridThirdStore();    	 
	    var cm03 = new Ext.grid.ColumnModel([{
	           id: 'col1',
	           header: "7：运行人员补充的安全措施",
	           dataIndex: 'col1',
	           width: 560,	           
	           editable: true,
	           align: 'left',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfContent()     
	        },{
	           id: 'col2',
	           header: "已执行",
	           dataIndex: 'col2',
	           width: 115,	           	           
	           align: 'center',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfExecution()      	            
	    }]);
	    cm03.defaultSortable = false;
	    
	    var grid03 = new Ext.grid.EditorGridPanel({
	    	id: 'editgrid03_m104',
	    	renderTo: 'grid03_m104',	    	
	    	layout: 'fit',
	        store: ds03,
	        cm: cm03,	        
	        width: 675,
	        height: 175,
	        autoExpandColumn: 'col1',
	        stripeRows:true,
	        columnLines : true,
	        //plugins: checkColumn,
	        viewConfig : {
	            forceFit: true,	            
	            scrollOffset: 0 // the grid will never have scrollbars
	        },
	        clicksToEdit: 2
	    });		    
	        
	        
    	//document.getElementById("grid04_m104").innerHTML = "";    	
    	var ds04 = new workpaper.store.dealPaper.rljxGridFourthStore();    	 
	    var cm04 = new Ext.grid.ColumnModel([{
	           id: 'col1',
	           header: "允许恢复工作时间",
	           dataIndex: 'col1',
	           width: 225,	           
	           editable: true,
	           align: 'left',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfContent() 
	        },{
	           id: 'col2',
	           header: "工 作 许 可 人",
	           dataIndex: 'col2',
	           width: 225,	           	           
	           align: 'center',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfExecution()
	        },{
	           id: 'col3',
	           header: "工 作 负 责 人",
	           dataIndex: 'col3',
	           width: 225,	           	           
	           align: 'center',
	           hidden: false,
	           resizable: false,
	           sortable: false,
	           editor: workpaper.ux.tools.getEditorOfExecution()
	    }]);
	    cm04.defaultSortable = false;
	    
	    var grid04 = new Ext.grid.EditorGridPanel({
	    	id: 'editgrid04_m104',
	    	renderTo: 'grid04_m104',	    	
	    	layout: 'fit',
	        store: ds04,
	        cm: cm04,	        
	        width: 675,
	        height: 125,
	        autoExpandColumn: 'col1',
	        stripeRows:true,
	        columnLines : true,
	        //plugins: checkColumn,
	        viewConfig : {
	            forceFit: true,	            
	            scrollOffset: 0 // the grid will never have scrollbars
	        },
	        clicksToEdit: 2
	    });		        
	    ds01.load();
	    ds02.load();
	    ds03.load();
	    ds04.load();

		//alert(document.getElementById("spanInput1").innerHTML);
    },
    
    //用工作票模板填充工作票主页
    onMainFormMenu2_modelFillClick : function(menuItem){
			workpaper.ux.tools.showPaperModelSelWin();
			Ext.getCmp("paperModelSelGrid").on("dblclick",selPaperModelRow,this);
			
		    function selPaperModelRow(eventObject){		   	
		    	alert("将用工作票模板内容填充工作票主页");
		    	Ext.getCmp("winpaperModelSel").hide();		    	
		    	Ext.getCmp("paperModelSelGrid").removeListener("dblclick",selPaperModelRow,this);
		    }    	
    },
    
    //添加工作票附页
    onMainFormMenu1_attachClick : function(menuItem){
    	menuItem.disable();
		this.attachFormMenu = new Ext.menu.Menu({
			id: 'attachFormMenu_m104',
			items: [
			 {
			 	id:'attachFormMenu_save_m104',
			 	//handler: onAttachFormMenu_saveClick,
				text: '保 存'			
			 },	{
			 	id:'attachFormMenu_del_m104',
			 	handler: onAttachFormMenu_delClick,
				text: '删 除'			
			 },{
			 	id:'attachFormMenu_print_m104',
			 	handler: function(menuItem){
    						workpaper.ux.tools.openPrinterWindow("print_Content_attach_m104","热力机械工作票附页");    		
						},
				text: '打印'			
			 }
			]
		});			      
		this.attachForm = new Ext.FormPanel({
			id: 'attachFormPanel_m104',			
			layout:'fit',
			margins:'0 0 0 0',
			frame: true,
			autoScroll: true,
			//defaults:{bodyStyle:'padding:10px'},			
			title: '工作票附页',
			tbar: [
	           {	                        
                id: 'attachMenuBtn_m104',	                        
                text:'附页操作',
                tooltip: {title:'',text:'针对当前工作票附页的操作菜单'},
                iconCls: 'preview-hide',
                menu: this.attachFormMenu
	           }
	        ],
	        html: "<div id='print_Content_attach_m104' width='680'><table style='background-color:white;padding:4px;white-space:nowrap;color:black;font-size:12px;' width='680' align='center' border='0'><tr><td align='center'><span style='font-size:22' align='center'><b>舟山朗熹发电有限责任公司<br>热&nbsp;&nbsp;力&nbsp;&nbsp;机&nbsp;&nbsp;械&nbsp;&nbsp;工&nbsp;&nbsp;作&nbsp;&nbsp;票&nbsp;&nbsp;附&nbsp;&nbsp;页</b></span></td></tr><tr height='25'><td><tr height='25'><td>部门（单位）：<input type='text' class='input' name='at_dept' id='at_dept_m104' style='width:170' />班组：<input type='text' class='input' name='at_workUnit' id='at_workUnit_m104' style='width:150' />工作票编号：<input type='text' class='input' name='at_paperId' id='at_paperId_m104' style='width:130' readonly='true'/></td></tr><tr><td><div id='at_grid01_m104' width='675'></div></td></tr><tr height='25'><td>工作票签发人：<input type='text' class='input' name='at_sendOutMan' id='at_sendOutMan_m104' style='width:85' />， (日期)<input type='text' class='input' name='at_sendOutManTime' id='at_sendOutManTime_m104' style='width:110' /> &nbsp;&nbsp;&nbsp;&nbsp;工作票填写人：<input type='text' class='input' name='at_fillMan' id='at_fillMan_m104' style='width:85' />， (日期)<input type='text' class='input' name='at_fillManTime' id='at_fillManTime_m104' style='width:110' /></td></tr><tr><td><div id='at_grid02_m104' width='675'></div></td></tr><tr height='25'><td>值长：<input type='text' class='input' name='at_curRunLeader' id='at_curRunLeader_m104' style='width:85' />， (日期)<input type='text' class='input' name='at_curRunLeaderTime' id='at_curRunLeaderTime_m104' style='width:110' /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;工作许可人：<input type='text' class='input' name='at_permissiveMan' id='at_permissiveMan_m104' style='width:85' />， (日期)<input type='text' class='input' name='at_permissiveManTime' id='at_permissiveManTime_m104' style='width:110' /></td></tr></table></div>"		
		});
		this.attachForm.on("afterrender",showAttachEditGrid,this);
		
		var theTab = Ext.getCmp('child_tabPanel_m104').add(this.attachForm);
		Ext.getCmp('child_tabPanel_m104').setActiveTab(theTab);
		
		//渲染工作票附页
	    function showAttachEditGrid(theAttachFormPanel){    	
	    	var ds01 = new workpaper.store.dealPaper.rljxGridFirstStore();    	 
		    var cm01 = new Ext.grid.ColumnModel([{
		           id: 'col1',
		           header: "5.检修工作要求工作许可人员执行的安全措施",
		           dataIndex: 'col1',
		           width: 560,	           
		           editable: true,
		           align: 'left',
		           hidden: false,
		           resizable: false,
		           sortable: false,
		           editor: workpaper.ux.tools.getEditorOfContent()     
		        },{
		           id: 'col2',
		           header: "已执行",
		           dataIndex: 'col2',
		           width: 115,	           	           
		           align: 'center',
		           hidden: false,
		           resizable: false,
		           sortable: false,
		           editor: workpaper.ux.tools.getEditorOfExecution()      	            
		    }]);
		    cm01.defaultSortable = false;
		    
		    var grid01 = new Ext.grid.EditorGridPanel({
		    	id: 'at_editgrid01_m104',
		    	renderTo: 'at_grid01_m104',	    	
		    	layout: 'fit',
		        store: ds01,
		        cm: cm01,	        
		        width: 675,
		        height: 435,
		        autoExpandColumn: 'col1',
		        stripeRows:true,
		        columnLines : true,
		        //plugins: checkColumn,
		        viewConfig : {
		            forceFit: true,	            
		            scrollOffset: 0 // the grid will never have scrollbars
		        },
		        clicksToEdit: 2
		    });
	 	
	    	var ds03 = new workpaper.store.dealPaper.rljxGridThirdStore();    	 
		    var cm03 = new Ext.grid.ColumnModel([{
		           id: 'col1',
		           header: "7.运行人员补充的安全措施",
		           dataIndex: 'col1',
		           width: 560,	           
		           editable: true,
		           align: 'left',
		           hidden: false,
		           resizable: false,
		           sortable: false,
		           editor: workpaper.ux.tools.getEditorOfContent()     
		        },{
		           id: 'col2',
		           header: "已执行",
		           dataIndex: 'col2',
		           width: 115,	           	           
		           align: 'center',
		           hidden: false,
		           resizable: false,
		           sortable: false,
		           editor: workpaper.ux.tools.getEditorOfExecution()      	            
		    }]);
		    cm03.defaultSortable = false;
		    
		    var grid03 = new Ext.grid.EditorGridPanel({
		    	id: 'at_editgrid02_m104',
		    	renderTo: 'at_grid02_m104',	    	
		    	layout: 'fit',
		        store: ds03,
		        cm: cm03,	        
		        width: 675,
		        height: 175,
		        autoExpandColumn: 'col1',
		        stripeRows:true,
		        columnLines : true,
		        //plugins: checkColumn,
		        viewConfig : {
		            forceFit: true,	            
		            scrollOffset: 0 // the grid will never have scrollbars
		        },
		        clicksToEdit: 2
		    });		    
		   
		    ds01.load();	  
		    ds03.load();
	    }	
		
		
	    //工作票附页的删除
	    function onAttachFormMenu_delClick (menuItem){
	    	Ext.getCmp('child_tabPanel_m104').remove(Ext.getCmp('attachFormPanel_m104'));    	
	    	Ext.destroy(Ext.getCmp('attachFormMenu_save_m104'),
	    				Ext.getCmp('attachFormMenu_del_m104'),
	    				Ext.getCmp('attachFormMenu_print_m104'),
	    				Ext.getCmp('attachFormMenu_m104'),
	    				Ext.getCmp('attachMenuBtn_m104'),	    				
	    				Ext.getCmp('attachFormPanel_m104')    				    							
	    			);
	    	Ext.getCmp('mainFormMenu1_attach_m104').enable();
	    	//onAttachFormMenu_saveClick = null;	    	
	    	onAttachFormMenu_delClick = null;
	    }		
			    	
    },
    
    //添加危险点与控制措施卡
    onMainFormMenu1_cardClick : function(menuItem){
    	this.cardNum = this.cardNum == null ? 0 : this.cardNum;
    	this.cardId = "card_m104_" +   this.cardNum ;    	
    	
    	this.cardFormMenu = this.cardFormMenu == null ? [] : this.cardFormMenu;	
		this.cardFormMenu[this.cardId] = new Ext.menu.Menu({
			id: 'cardFormMenu_' + this.cardId,
			items: [
			 {
			 	id: this.cardId + '_save',
			 	//handler: onCardFormMenu_saveClick,
				text: '保 存'			
			 },	{
			 	id: this.cardId + '_del',
			 	handler: onCardFormMenu_delClick,
				text: '删 除'			
			 },{
			 	id: this.cardId + '_print',
			 	handler: function(menuItem){
    						workpaper.ux.tools.openPrinterWindow("print_Content_card" + menuItem.id.replace('_print','') ,"热力机械工作票——危险点与控制措施卡");    		
						},
				text: '打印'			 		
			 },{
			 	id: this.cardId + '_model',
			 	//handler: onCardFormMenu_modelClick,
				text: '保存为模板'			
			 },{
			 	id: this.cardId + '_modelFill',
			 	handler: onCardFormMenu_modelFillClick,
				text: '用模板填充'			
			 },{
			 	id: this.cardId + '_modelEdit',
			 	handler: onCardFormMenu_modelEditClick,
				text: '用模板填充并编辑'
			 }
			]
		});	
		
		this.cardForm = this.cardForm == null ? [] : this.cardForm;			      
		this.cardForm[this.cardId] = new Ext.FormPanel({
			id: 'cardFormPanel_' + this.cardId,			
			layout:'fit',
			margins:'0 0 0 0',
			frame: true,
			autoScroll: true,
			//defaults:{bodyStyle:'padding:10px'},		
			title: '危险点与控制措施卡 ' + this.cardNum,
			tbar: [
	           {	                        
                id: 'cardMenuBtn_' + this.cardId,	                        
                text:'危险点与控制措施卡操作',
                tooltip: {title:'',text:'针对当前危险点与控制措施卡的操作菜单'},
                iconCls: 'preview-hide',
                menu: this.cardFormMenu[this.cardId]
	           }
	        ],
	        html: "<div id='print_Content_card" + this.cardId + "' width='680'><table style='background-color:white;padding:4px;white-space:nowrap;color:black;font-size:12px;' width='680' align='center' border='0'><tr><td height='50'>&nbsp;</td></tr><tr><td height='25' align='center'><input type='text' class='input' name='card_title' id='card" + this.cardId + "_title' style='width:640;font-size:18;text-align:center' /></td></tr><tr height='25'><td>&nbsp;</td></tr><tr height='25'><td><b>工作票编号：<span id='card" + this.cardId + "_paperId'>ZS20090803231954001</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;时间：<span id='card" + this.cardId + "_fillTime'>2009年08月03日</span></b></td></tr><tr><td><div id='card" + this.cardId + "_grid01' width='675'><i><font color='red'>请用菜单操作完成内容填充</font></i></div></td></tr><tr height='25'><td>工作人员(临工)签名：<input type='text' class='input' name='card_workers' id='card" + this.cardId + "_workers' style='width:550' /></td></tr><tr height='25'><td>工作负责人签名：<input type='text' class='input' name='card_principal' id='card" + this.cardId + "_principal' style='width:170' /></td></tr></table></div>"		
		});		
		
		var theTab = Ext.getCmp('child_tabPanel_m104').add(this.cardForm[this.cardId]);
		Ext.getCmp('child_tabPanel_m104').setActiveTab(theTab);
		this.cardNum = this.cardNum + 1;
		
		//用模板填充
		function onCardFormMenu_modelFillClick(menuItem){
			workpaper.ux.tools.showDangersSelWin();
			Ext.getCmp("dangersSelGrid").on("dblclick",selDangerRow,this);						
			var theCardId = menuItem.id.replace('_modelFill','');
			
		    function selDangerRow(eventObject){		   	
		    	Ext.fly('card' + theCardId + '_title').dom.value = '弹簧管压力表、膜盒式风压表检修危险点控制措施';
		    	Ext.fly('card' + theCardId + '_grid01').dom.innerHTML = "<p><table cellspacing='0' cellpadding='0' border='1'><tbody><tr><td width='108' valign='top'><div><b>作业<span>(操作)内容</span></b></div></td><td width='108' valign='top'><div><b>危 险 点</b></div></td><td width='552' valign='top'><div align='center'><b>控 制 措 施</b></div></td><td width='144' valign='top'><div align='center'><b>依<span>&nbsp;据</span></b></div></td></tr><tr><td width='108'><div>开工前准备及安全交底</div></td><td width='108'><div>工作人员（临工）作业内容不明确、安全交底不清楚</div></td><td width='552' valign='top'><div>1、工作负责人组织工作人员（临工）明确工作任务及分工情况（&nbsp;）。2、工作负责人组织工作人员（临工）进行安全交底：⑴、工作人员（临工）穿戴好劳动保护用品（工作负责人、监护人佩戴臂章）（&nbsp;）；⑵、工作现场严禁吸烟，严禁酒后作业（&nbsp;）；⑶、工作人员（临工）牢记&ldquo;四不伤害&rdquo;原则：我不伤害他人、我不被他人伤害、我不自己伤害自己、我保护他人不被伤害（&nbsp;）；⑷、不熟悉电气工具使用方法的人员不准擅自使用电气工具（&nbsp;）；⑸、作业前对工具、安全工器具进行检查，不完整的工器具不准使用（&nbsp;）；⑹、禁止冒险作业、野蛮施工，拆下的零部件分类摆放（&nbsp;）；⑺、不得触碰与工作无关的设备（&nbsp;）；⑻、工作人员在作业中碰到问题时，应停止工作并及时向工作负责人询问，弄清问题后才可继续工作（&nbsp;）；⑼、严禁擅自扩大工作范围及工作任务（&nbsp;）；⑽、工作结束要做到工完、料尽、场地清（&nbsp;）；⑾工作人员（临工）必须严格遵守《安规》和公司有关安全规章制度（&nbsp;）。3、工作负责人组织工作人员（临工）分析危险点并落实控制措施（&nbsp;）。</div></td><td width='144'><div>《热机安规》第47条</div><div>《热机安规》第55条</div><div>《热机安规》第5.5.1条</div><div>&nbsp;</div></td></tr><tr><td width='108'><div>办理工作票</div></td><td width='108'><div>安全措施未落实</div></td><td width='552'><div>1、作业前，办理工作票，确认安全措施完善，组织人员宣读、签字后方可施工。</div></td><td width='144'><div>《热机安规》第<span>70条</span></div><div>《热机安规》第<span>77条</span></div></td></tr><tr><td width='108'><div>故障检查</div></td><td width='108'><div>误碰运行设备造成事故</div></td><td width='552'><div>与运行人员核实要作业的设备，两人或两人以上才能工作，要有一人监护。</div></td><td width='144'><div>《热机安规》第<span>5.6.1条</span></div></td></tr><tr><td width='108'><div>故障排除恢复</div></td><td width='108'><div>引起事故</div></td><td width='552'><div>1．恢复时检查二次阀门是否打开。<span>2.作好事故预想。</span></div></td><td width='144' valign='top'><div><b>&nbsp;</b></div></td></tr></tbody></table></p>";
		    	Ext.getCmp("winDangersSel").hide();
		    	Ext.getCmp("dangersSelGrid").removeListener("dblclick",selDangerRow,this);
		    }			
		}
		
		//用模板填充并编辑
		function onCardFormMenu_modelEditClick(menuItem){
			workpaper.ux.tools.showDangersSelWin();
			Ext.getCmp("dangersSelGrid").on("dblclick",selDangerRowAndEdit,this);						
			var theCardId = menuItem.id.replace('_modelEdit','');
			
		    function selDangerRowAndEdit(eventObject){		   	
		    	Ext.fly('card' + theCardId + '_title').dom.value = '弹簧管压力表、膜盒式风压表检修危险点控制措施';
		    	Ext.fly('card' + theCardId + '_grid01').dom.innerHTML = "";
				var cardFCKeditor = new Ext.form.TextArea({
					id: 'cardFCKeditor_' + theCardId,
					renderTo: 'card' + theCardId + '_grid01',
					name: 'cardFCKeditor_' + theCardId,
					hideLabel: true,
					width: 675,
					height: 600	            
				});
				workpaper.ux.tools.createFCKeditorAndReplaceEl('cardFCKeditor_' + theCardId);		    	
		    	Ext.fly('cardFCKeditor_' + theCardId).dom.value = "<p><table cellspacing='0' cellpadding='0' border='1'><tbody><tr><td width='108' valign='top'><div><b>作业<span>(操作)内容</span></b></div></td><td width='108' valign='top'><div><b>危 险 点</b></div></td><td width='552' valign='top'><div align='center'><b>控 制 措 施</b></div></td><td width='144' valign='top'><div align='center'><b>依<span>&nbsp;据</span></b></div></td></tr><tr><td width='108'><div>开工前准备及安全交底</div></td><td width='108'><div>工作人员（临工）作业内容不明确、安全交底不清楚</div></td><td width='552' valign='top'><div>1、工作负责人组织工作人员（临工）明确工作任务及分工情况（&nbsp;）。2、工作负责人组织工作人员（临工）进行安全交底：⑴、工作人员（临工）穿戴好劳动保护用品（工作负责人、监护人佩戴臂章）（&nbsp;）；⑵、工作现场严禁吸烟，严禁酒后作业（&nbsp;）；⑶、工作人员（临工）牢记&ldquo;四不伤害&rdquo;原则：我不伤害他人、我不被他人伤害、我不自己伤害自己、我保护他人不被伤害（&nbsp;）；⑷、不熟悉电气工具使用方法的人员不准擅自使用电气工具（&nbsp;）；⑸、作业前对工具、安全工器具进行检查，不完整的工器具不准使用（&nbsp;）；⑹、禁止冒险作业、野蛮施工，拆下的零部件分类摆放（&nbsp;）；⑺、不得触碰与工作无关的设备（&nbsp;）；⑻、工作人员在作业中碰到问题时，应停止工作并及时向工作负责人询问，弄清问题后才可继续工作（&nbsp;）；⑼、严禁擅自扩大工作范围及工作任务（&nbsp;）；⑽、工作结束要做到工完、料尽、场地清（&nbsp;）；⑾工作人员（临工）必须严格遵守《安规》和公司有关安全规章制度（&nbsp;）。3、工作负责人组织工作人员（临工）分析危险点并落实控制措施（&nbsp;）。</div></td><td width='144'><div>《热机安规》第47条</div><div>《热机安规》第55条</div><div>《热机安规》第5.5.1条</div><div>&nbsp;</div></td></tr><tr><td width='108'><div>办理工作票</div></td><td width='108'><div>安全措施未落实</div></td><td width='552'><div>1、作业前，办理工作票，确认安全措施完善，组织人员宣读、签字后方可施工。</div></td><td width='144'><div>《热机安规》第<span>70条</span></div><div>《热机安规》第<span>77条</span></div></td></tr><tr><td width='108'><div>故障检查</div></td><td width='108'><div>误碰运行设备造成事故</div></td><td width='552'><div>与运行人员核实要作业的设备，两人或两人以上才能工作，要有一人监护。</div></td><td width='144'><div>《热机安规》第<span>5.6.1条</span></div></td></tr><tr><td width='108'><div>故障排除恢复</div></td><td width='108'><div>引起事故</div></td><td width='552'><div>1．恢复时检查二次阀门是否打开。<span>2.作好事故预想。</span></div></td><td width='144' valign='top'><div><b>&nbsp;</b></div></td></tr></tbody></table></p>";
		    	Ext.getCmp("winDangersSel").hide();
		    	Ext.getCmp("dangersSelGrid").removeListener("dblclick",selDangerRowAndEdit,this);
		    }			
		}
		
	    //危险点与控制措施卡删除
	    function onCardFormMenu_delClick(menuItem){	    	  	
	    	var theCardId = menuItem.id.replace('_del','');	    	
	    	Ext.getCmp('child_tabPanel_m104').remove(Ext.getCmp('cardFormPanel_' + theCardId));    	
	    	Ext.destroy(Ext.getCmp(theCardId + '_save'),
	    				Ext.getCmp(theCardId + '_del'),
	    				Ext.getCmp(theCardId + '_print'),
	    				Ext.getCmp('cardFormMenu_' + theCardId),
	    				Ext.getCmp('cardMenuBtn_' + theCardId),	    				
	    				Ext.getCmp('cardTinyMce_' + theCardId),
	    				Ext.getCmp('cardFormPanel_' + theCardId)    				    							
	    			);
	    	//this.cardNum = null;//错误
	    	//onCardFormMenu_saveClick = null;
	    	//onCardFormMenu_printClick = null;
	    	onCardFormMenu_delClick = null;	    	
	    }			    	
    }
    
    
        
}); 